/*
 * @Author: your name
 * @Date: 2019-12-31 17:11:46
 * @LastEditTime : 2020-01-02 10:31:35
 * @LastEditors  : Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \pc\src\pages\ValueManage\PriceManage\PriceEdit\utils\alteration.js
 */
import _ from 'lodash';

export const buildTree = (list, pid = '0') => {
  const root = _.filter(list, data => data.pid === pid);
  if (root && root.length > 0) {
    _.forEach(root, element => {
      const x = element;
      x.children = buildTree(list, x.id);
    });
  }
  return root;
};

export const getExpandedRowKeys = list => {
  const expandedRowKeys = [];
  if (list && list.length > 0) {
    _.forEach(list, value => {
      if (value) expandedRowKeys.push(value.id);
    });
  }
  return expandedRowKeys;
};
